New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking: fix config loading (fixes #11510, fixes #11559, fixes #11586) #11546
Conversation
overrides
settings in shareable configs overwrite extender's setting (fixes #11510)overrides
setting to not affect extendee files (fixes #11510)
overrides
setting to not affect extendee files (fixes #11510)a864ae1
to
89b3292
Compare
@mysticatea PR #11388 has been merged. It also looks like this needs a rebase/merge. Once that's done, feel free to request my review or ping me and I'll review this. Thanks! |
88e1649
to
2fc4464
Compare
Hi. I updated this PR and I think ready for review! |
I updated this PR to resolve conflicts. |
I will revert moved files because I have found that Git didn't recognize |
Co-Authored-By: Teddy Katz <teddy.katz@gmail.com>
Thank you very much for making time to review this large PR! I think that I fixed all the suggested changes. |
This looks good to me after #11546 (comment) is addressed. Also, I think this PR should remove these lines from the migration guide. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Thank you very much for the review of this huge PR! |
What is the purpose of this pull request? (put an "X" next to item)
[X] Bug fix: fixes #11510, fixes #11559, fixes #11586
[X] Other, please explain: the refactoring of configurations
Closes #10928 because I realized that this PR does the same thing as #10928 (comment).
What changes did you make? (Give an overview)
This PR fixes three bugs along with the refactoring of configurations.
I'm sorry that this diff is huge.
All new files are in
lib/cli-engine/
directory because onlyCLIEngine
uses those.The refactoring does the following items:
lib/cli-engine/config-array/
directory.lib/cli-engine/config-array-factory.js
creates the internal structure from each config file..eslintrc.js
.lib/cli-engine/cascading-config-array-factory.js
handles cascading of config files and CLI options.lib/cli-engine/config-array/config-array.js
owns loaded plugins and parsers.lib/cli-engine/config-array-factory.js
loads plugins and parsers.Linter#getRules()
returns the map that contains built-in rules, user-defined rules (byLinter#defineRule()
), and plugin rules ofConfigArray
instance the lastLinter#verify()
call used.CLIEngine#getRules()
returns the map that contains built-in rules and plugin rules ofConfigArray
instances the lastCLIEngine#executeOnFiles()
orCLIEngine#executeOnText()
call used.lib/cli-engine/file-enumerator.js
finds target files by processing glob patterns. While iterating files, it loads the config file of each directory before iterate files on the directory, so we can use the config files to determine target files. (But, it doesn't use the config files to determine target files yet.)I describe file mapping of before/after the refactoring. There are details for each new file on the top of the source code.
lib/config-ops.js
(
merge
method)lib/cli-engine/config-array/config-array.js
lib/cli-engine/config-array/config-dependency.js
lib/cli-engine/config-array/extracted-config.js
lib/config-ops.js
(
pathMatchesGlobs
method)lib/cli-engine/config-array/override-tester.js
lib/config.js
lib/cli-engine/cascading-config-array-factory.js
lib/config/config-file.js
lib/util/file-finder.js
lib/cli-engine/config-array-factory.js
lib/util/glob-utils.js
lib/util/glob.js
lib/cli-engine/file-enumerator.js
Therefore, appropriate tests to the moved logics are moved to new files.
Tests in
tests/lib/config.js
moved to tests/lib/cli-engine/cascading-config-array-factory.js#L88. It's implemented in theCascadingConfigArrayFactory#getConfigArrayForFile()
method.Tests for
applyExtends()
,load()
, andresolve()
intests/lib/config/config-file.js
moved to tests/lib/cli-engine/config-array-factory.js#L1216. It's implemented in theConfigArrayFactory
class.Tests for
load()
andloadAll()
intests/lib/config/plugins.js
moved to tests/lib/cli-engine/config-array-factory.js#L2031. It's implemented in theConfigArrayFactory
class.Tests for
merge()
intests/lib/config/config-ops.js
moved to tests/lib/cli-engine/config-array/config-array.js#L349. It's implemented in theConfigArray#extractConfig()
method.Tests for
pathMatchesGlobs()
intests/lib/config/config-ops.js
moved to tests/lib/cli-engine/config-array/override-tester.js#L101. It's implemented inOverrideTester#test()
method.Tests for
listFilesToProcess()
intests/lib/util/glob-utils.js
moved to tests/lib/cli-engine/file-enumerator.js#L171. It's implemented in theFileEnumerator#iterateFiles()
method.Tests for
resolveFileGlobPattern()
intests/lib/util/glob-utils.js
moved to tests/lib/cli-engine.js#L3412. The newFileEnumerator
no longer uses this logic, but it's a public API ofCLIEngine
. So we have to keep it.And I added some
@typedef
comments for VSCode IntelliSense.Is there anything you'd like reviewers to focus on?
I found an additional breaking change (as a bug fix) about plugin loading. Currently, even if a configuration has no
plugins
field,CLIEngine#executeOnFiles()
andCLIEngine#executeOnText()
can use plugin rules that the previous calls loaded. After this PR,CLIEngine#executeOnFiles()
andCLIEngine#executeOnText()
will report error messages consistently if plugins were not found in configuration.Related to that,
Linter#getRules()
andCLIEngine#getRules()
will change:Linter#getRules()
will return the rules, including built-in rules, user-defined rules, and only the plugin rules that the lastLinter#verify()
loaded.CLIEngine#getRules()
will return the rules, including built-in rules and only the plugin rules that the lastCLIEngine#executeOnFiles()
orCLIEngine#executeOnText()
loaded.I think that this change is good because formatters can access to unrelated rules (via RFC 10) before this PR and we already have a getter to get information of the last
Linter#verify()
call;Linter#getSourceCode()
.